import { createRouter, createWebHistory } from "vue-router";

import Login from "./components/Login.vue";
import PageLayout from "./components/PageLayout.vue";
import Welcome from "./pages/Welcome.vue";
import ClassificationParams from "./pages/ClassificationParams.vue";
import DataReport from "./pages/DataReport.vue";
import GoodsClassification from "./pages/GoodsClassification.vue";
import GoodsList from "./pages/GoodsList.vue";
import OrderList from "./pages/OrderList.vue";
import PermissionsList from "./pages/PermissionsList.vue";
import RoleList from "./pages/RoleList.vue";
import UserList from "./pages/UserList.vue";
import CreateProduct from "./pages/CreateProduct.vue";
import EditProduct from "./pages/EditProduct.vue";

const routes = [
  {
    path: "/",
    component: PageLayout,
    children: [
      {
        path: "/user/user-list",
        component: UserList,
        name: "UserList",
      },
      {
        path: "/goods/classification-params",
        component: ClassificationParams,
        name: "ClassificationParams",
      },
      {
        path: "/statistics/data-report",
        component: DataReport,
        name: "DataReport",
      },
      {
        path: "/goods/goods-classification",
        component: GoodsClassification,
        name: "GoodsClassification",
      },
      {
        path: "/goods/goods-list",
        component: GoodsList,
        name: "GoodsList",
      },
      {
        path: "/order/order-list",
        component: OrderList,
        name: "OrderList",
      },
      {
        path: "/permissions/permissions-list",
        component: PermissionsList,
        name: "PermissionsList",
      },
      {
        path: "/permissions/role-list",
        component: RoleList,
        name: "RoleList",
      },
      {
        path: "/welcome",
        component: Welcome,
        name: "Welcome",
      },
      {
        path: "/",
        redirect: "/login"
      },{
        path: "/goods/goods-list/add",
        component: CreateProduct,
        name: "CreateProduct",
      },
      {
        path: "/goods/goods-list/edit",
        component: EditProduct,
        name: "EditProduct",
      }
    ],
  },
  {
    path: "/login",
    component: Login,
    name: "Login",
  },
];

const router = createRouter({
  history: createWebHistory(),
  routes,
});

export default router;
